const path = require('path');
const webpack = require('webpack');
const Timestamp = new Date().getTime();
const isProduction = process.env.NODE_ENV == 'production';

function resolveSrc(_path) {
  return path.join(__dirname, _path);
}
// vue.config.js
module.exports = {
  transpileDependencies: ['vue-clamp', 'resize-detector'],
  productionSourceMap: !isProduction,
  publicPath: '/',
  lintOnSave: true,
  devServer: {
    inline: false,
    port: 8100,
    proxy: {
      '': {
        target: 'https://manage.tradingsignal.ai/api',
        changeOrigin: true,
        logLevel: 'debug',
      },
    }
  },
  configureWebpack: {
    // Set up all the aliases we use in our app.
    output: {
      filename: `js/[name].${Timestamp}.js`,
      chunkFilename: `js/[name].${Timestamp}.js`
    },
    resolve: {
      alias: {
        src: resolveSrc('src'),
        // 'chart.js': 'chart.js/dist/Chart.js'
      }
    },
    plugins: [
      new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 6
      })
    ]
  },
  pluginOptions: {

  },
  css: {
    // Enable CSS source maps.
    sourceMap: process.env.NODE_ENV !== 'production',
    loaderOptions: {
      sass: {
        // additionalData: `
        //   @import "~@/style/global.scss";
        // `
      },
      less: {
        javascriptEnabled: true,
        modifyVars: {
          // 'notify-primary-background-color':'red',
          // 'hack':`true;@import "${resolve('./src/style/mine_vant.less')}";`
        }
      }
    }
  },
  // chainWebpack: config => {
  //   const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
  //   types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
  // }
};
